// import { client } from "./oss";

function  base64toBlob(dataURI,type){
	   let binary = atob(dataURI.split(',')[1]);
	  let array = [];
	   for(let i = 0; i < binary.length; i++) {
	   array.push(binary.charCodeAt(i));
	   }
	   return new Blob([new Uint8Array(array)], {type:type });
}
function uploadFile(pathKey, file, progress = () => {}) {
  const uploadPath = {
    avatar: "exam/Resources/Avatars/",
    course: "exam/Resources/Course/"
  };
  const { name } = file;
  //文件后缀
	console.log(typeof(name),'需要上传的文件')
  const suffix = name.substring(name.lastIndexOf("."), name.length);
  const fileName = generateId();
  return client.multipartUpload(
    `${uploadPath[pathKey]}${fileName}${suffix}`,
    file,
    {
      progress: p => {
        progress(parseInt((p * 100).toFixed(2)));
      }
    }
  );
}
function dateCompare(startDate, endDate) {
	  console.log((endDate-startDate)/1000 ,'是的发送到')
		// // 计算截止时间
		// startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
		// // 计算详细项的截止时间
		// endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
		// if (startDate <= endDate) {
		// 	return true
		// } else {
		// 	return false
		// }
	}
export default {
  base64toBlob,
	uploadFile,
	dateCompare
};